using System;
using EMR.EMREditor.Src.Document;

namespace EMR.DocumentEditor
{
	public class ZYTextHRule : ZYTextElement
	{

		public override bool isField()
		{
			return false;
		}
		public override bool isTextElement()
		{
			return false;
		}
		public override string ToEMRString()
		{
			return "";
		}
		public override bool isNewLine()
		{
			return true;
		}
		public override bool OwnerWholeLine()
		{
			return true;
		}
		public override string GetXMLName()
		{
			return ZYTextConst.c_HR ;
		}

		public System.Drawing.Color ForeColor
		{
			get{ return myAttributes.GetColor(ZYTextConst.c_ForeColor );}
			set{ myAttributes.SetValue( ZYTextConst.c_ForeColor , value);}
		}
		public int LineHeight
		{
			get{ return myAttributes.GetInt32( ZYTextConst.c_Height );}
			set
			{
				if( value >= 1 && value <=10)
					myAttributes.SetValue( ZYTextConst.c_Height ,value );
			}
		}
		public override bool RefreshSize()
		{
			this.Width = myParent.GetClientWidth();
			this.Height = myOwnerDocument.DefaultRowHeight;
			return true;
		}

		public override bool RefreshView()
		{
			int h = this.LineHeight ;
			if( h <= 0 ) h = 1 ;
			System.Drawing.Pen myPen = myOwnerDocument.View._CreatePen( this.ForeColor , h);
			int intTop = this.RealTop + (int)(( this.Height - h ) /2 ) + 1;
			myOwnerDocument.View.DrawLine( myPen , this.RealLeft + 10  ,intTop , this.RealLeft + this.Width - 10  , intTop );
			return true ;
		}

		public ZYTextHRule()
		{
			this.LineHeight = 1 ;
		}
	}
}
